package com.ruoyi.project.system.onlineWeb.controller;

import java.util.List;


import com.ruoyi.project.jiaowu.totalcoursemain.domain.TbTotalCourseMain;
import com.ruoyi.project.jiaowu.totalcoursemain.service.ITbTotalCourseMainService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.onlineWeb.domain.OnlineWeb;
import com.ruoyi.project.system.onlineWeb.service.IOnlineWebService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * jiaowuOnlineController
 * 
 * @author lv
 * @date 2020-02-13
 */
@Controller
@RequestMapping("/jiaowuOnline/onlineWeb")
public class OnlineWebController extends BaseController
{
    private String prefix = "system/onlineWeb";

    @Autowired
    private IOnlineWebService onlineWebService;

    @Autowired
    private ITbTotalCourseMainService tbTotalCourseMainService;

    @RequiresPermissions("jiaowuOnline:onlineWeb:view")
    @GetMapping()
    public String onlineWeb(ModelMap map)
    {
        List<TbTotalCourseMain> list = tbTotalCourseMainService.selectTbTotalCourseMainList(null);
        map.put("courseList",list);
        return prefix + "/onlineWeb";
    }

    /**
     * 查询jiaowuOnline列表
     */
    @RequiresPermissions("jiaowuOnline:onlineWeb:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(OnlineWeb onlineWeb)
    {
        startPage();
        List<OnlineWeb> list = onlineWebService.selectOnlineWebList(onlineWeb);
        return getDataTable(list);
    }

    /**
     * 导出jiaowuOnline列表
     */
    @RequiresPermissions("jiaowuOnline:onlineWeb:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(OnlineWeb onlineWeb)
    {
        List<OnlineWeb> list = onlineWebService.selectOnlineWebList(onlineWeb);
        ExcelUtil<OnlineWeb> util = new ExcelUtil<OnlineWeb>(OnlineWeb.class);
        return util.exportExcel(list, "onlineWeb");
    }

    /**
     * 新增jiaowuOnline
     */
    @GetMapping("/add")
    public String add(ModelMap map)
    {
        List<TbTotalCourseMain> list = tbTotalCourseMainService.selectTbTotalCourseMainList(null);
        map.put("courseList",list);
        return prefix + "/add";
    }

    /**
     * 新增保存jiaowuOnline
     */
    @RequiresPermissions("jiaowuOnline:onlineWeb:add")
    @Log(title = "jiaowuOnline", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(OnlineWeb onlineWeb)
    {
        return toAjax(onlineWebService.insertOnlineWeb(onlineWeb));
    }

    /**
     * 修改jiaowuOnline
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        OnlineWeb onlineWeb = onlineWebService.selectOnlineWebById(id);
        mmap.put("onlineWeb", onlineWeb);
        List<TbTotalCourseMain> list = tbTotalCourseMainService.selectTbTotalCourseMainList(null);
        mmap.put("courseList",list);
        return prefix + "/edit";
    }

    /**
     * 修改保存jiaowuOnline
     */
    @RequiresPermissions("jiaowuOnline:onlineWeb:edit")
    @Log(title = "jiaowuOnline", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(OnlineWeb onlineWeb)
    {
        return toAjax(onlineWebService.updateOnlineWeb(onlineWeb));
    }

    /**
     * 删除jiaowuOnline
     */
    @RequiresPermissions("jiaowuOnline:onlineWeb:remove")
    @Log(title = "jiaowuOnline", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        //System.err.println(ids);
        return toAjax(onlineWebService.deleteOnlineWebByIds(ids));
    }

}
